Skip to content

Conversation

@danielrosehill
Copy link

@danielrosehill danielrosehill commented Dec 4, 2025

User description

Summary

This PR enhances the install script to better support AI coding assistants (Claude Code, Cursor, etc.) by:

  • Downloading llm.txt locally to ~/.config/mcpm/llm.txt during installation for fast, offline access
  • Detecting AI agent instruction files in common locations:
    • ~/CLAUDE.md
    • ~/.claude/CLAUDE.md
    • ~/agents.md
    • ~/.config/claude/CLAUDE.md
  • Offering to append MCPM documentation reference with both local and remote URLs

What gets added to user's instruction files

<!-- MCPM-AI-AGENT-DOCS -->
## MCPM (Model Context Protocol Manager)

MCPM is installed on this system for managing MCP servers. For comprehensive
CLI documentation optimized for AI agents, see:

- **Local**: ~/.config/mcpm/llm.txt
- **Remote** (fallback): https://raw.githubusercontent.com/pathintegral-institute/mcpm.sh/main/llm.txt

Key commands: `mcpm search`, `mcpm install`, `mcpm ls`, `mcpm run`
<!-- END-MCPM-AI-AGENT-DOCS -->

Features

  • Uses HTML comment markers to prevent duplicate insertions on reinstall
  • Prompts user before modifying any files (opt-in)
  • Gracefully handles missing files or failed downloads
  • Provides GitHub URL as fallback if local file unavailable

Test plan

  • Run install script on fresh system, verify llm.txt downloaded
  • Test with existing CLAUDE.md file, verify prompt appears
  • Test idempotency - reinstall should not duplicate section
  • Test without any AI instruction files - should complete silently

PR Type

Enhancement


Description

  • Downloads llm.txt documentation to ~/.config/mcpm/llm.txt for offline AI agent access

  • Detects common AI instruction files (CLAUDE.md, agents.md) in standard locations

  • Offers to append MCPM documentation reference with local and remote URLs

  • Uses HTML comment markers to prevent duplicate insertions on reinstall


Diagram Walkthrough

flowchart LR
  A["Install Script"] --> B["Download llm.txt"]
  A --> C["Detect AI Instruction Files"]
  C --> D["Prompt User"]
  D --> E["Append MCPM Docs Reference"]
  B --> F["~/.config/mcpm/llm.txt"]
  E --> G["User's AI Agent Files"]
Loading

File Walkthrough

Relevant files
Enhancement
install
Add AI agent docs integration function                                     

pages/install

  • Added setup_ai_agent_docs() function to download and integrate MCPM
    documentation
  • Downloads llm.txt from GitHub to ~/.config/mcpm/llm.txt for offline
    access
  • Detects AI instruction files in four common locations (CLAUDE.md,
    agents.md variants)
  • Prompts user before appending MCPM documentation reference with
    idempotency markers
  • Integrated new function into main installation workflow
+61/-1   

Summary by CodeRabbit

  • New Features
    • Automatic AI agent documentation setup: Installation now downloads and integrates AI agent documentation into your system. Instruction files are automatically enhanced with MCPM-AI documentation sections containing key commands, local paths, and remote resource references. This ensures developers have immediate, integrated access to AI agent capabilities and guidance without requiring separate documentation lookups.

✏️ Tip: You can customize this high-level summary in your review settings.

- Download llm.txt to ~/.config/mcpm/ during installation
- Detect common AI agent instruction files (CLAUDE.md, agents.md)
- Offer to append MCPM documentation reference with local/remote URLs
- Use HTML comment markers to prevent duplicate insertions
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

A new setup_ai_agent_docs() function was added to the installation script that downloads AI agent documentation for MCPM, creates a configuration directory, and appends documentation blocks to candidate instruction files during the install process.

Changes

Cohort / File(s) Summary
AI Agent Documentation Setup
pages/install
New setup_ai_agent_docs() function that downloads documentation (llm.txt), creates ~/.config/mcpm directory, iterates through candidate instruction files, and appends MCPM-AI-AGENT-DOCS section if not already present. Integrated into main installation flow after verify_installation. Minor whitespace addition with no functional impact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify download error handling and fallback messaging logic
  • Confirm file iteration and conditional appending logic for avoiding duplicate documentation blocks
  • Validate path construction and directory creation behavior

Poem

🐰 A setup so fair, with docs from afar,
Our AI agent now has its star,
Config directories, instruction files bright,
Documentation appended just right!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add AI agent docs integration to install script' directly and clearly describes the main change: integrating AI agent documentation into the installation process.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 4, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Unsafe file append

Description: Appending unvalidated here-doc content to user-controlled files based solely on a
single-character prompt may enable unintended modification of sensitive dotfiles if an
attacker can influence environment variables or symlinks (e.g., target files being
symlinks), so writes should avoid following symlinks or should validate targets before
appending.
install [215-221]

Referred Code
    read -p "Would you like to add MCPM documentation reference? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        echo "$MCPM_SECTION" >> "$file"
        success "Added MCPM documentation reference to $file"
    fi
fi
Unverified download

Description: Downloading documentation over HTTPS without verifying integrity (no checksum, signature,
or pinned certificate) risks TOFU issues and supply-chain tampering if the remote content
is compromised, which then gets stored under ~/.config/mcpm/llm.txt and referenced by
agents.
install [176-181]

Referred Code
if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
    info "Saved AI agent documentation to $MCPM_LLM_TXT"
else
    info "Could not download llm.txt (will use GitHub URL as fallback)"
fi
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logs: Newly added actions (downloading documentation and modifying user files) are not logged in
an audit-friendly manner, making it unclear who consented and what files were changed.

Referred Code
# Function to setup AI agent integration
setup_ai_agent_docs() {
    MCPM_CONFIG_DIR="$HOME/.config/mcpm"
    MCPM_LLM_TXT="$MCPM_CONFIG_DIR/llm.txt"
    LLM_TXT_URL="https://raw.githubusercontent.com/pathintegral-institute/mcpm.sh/main/llm.txt"

    # Download llm.txt to config directory
    info "Downloading MCPM documentation for AI agents..."
    mkdir -p "$MCPM_CONFIG_DIR"
    if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
        info "Saved AI agent documentation to $MCPM_LLM_TXT"
    else
        info "Could not download llm.txt (will use GitHub URL as fallback)"
    fi

    # Check for AI agent instruction files
    AI_INSTRUCTION_FILES=(
        "$HOME/CLAUDE.md"
        "$HOME/.claude/CLAUDE.md"
        "$HOME/agents.md"
        "$HOME/.config/claude/CLAUDE.md"


 ... (clipped 37 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Silent failures: The curl download failure only logs a generic info message without exit status or retry,
and file append operations do not check write errors or handle non-writable files.

Referred Code
# Download llm.txt to config directory
info "Downloading MCPM documentation for AI agents..."
mkdir -p "$MCPM_CONFIG_DIR"
if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
    info "Saved AI agent documentation to $MCPM_LLM_TXT"
else
    info "Could not download llm.txt (will use GitHub URL as fallback)"
fi

# Check for AI agent instruction files
AI_INSTRUCTION_FILES=(
    "$HOME/CLAUDE.md"
    "$HOME/.claude/CLAUDE.md"
    "$HOME/agents.md"
    "$HOME/.config/claude/CLAUDE.md"
)

MCPM_MARKER="<!-- MCPM-AI-AGENT-DOCS -->"

read -r -d '' MCPM_SECTION << 'MCPM_EOF'



 ... (clipped 28 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
Unstructured logs: The script uses human-readable echo/info messages without structured format, which may
hinder auditing while including full file paths in prompts and messages.

Referred Code
# Download llm.txt to config directory
info "Downloading MCPM documentation for AI agents..."
mkdir -p "$MCPM_CONFIG_DIR"
if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
    info "Saved AI agent documentation to $MCPM_LLM_TXT"
else
    info "Could not download llm.txt (will use GitHub URL as fallback)"
fi

# Check for AI agent instruction files
AI_INSTRUCTION_FILES=(
    "$HOME/CLAUDE.md"
    "$HOME/.claude/CLAUDE.md"
    "$HOME/agents.md"
    "$HOME/.config/claude/CLAUDE.md"
)

MCPM_MARKER="<!-- MCPM-AI-AGENT-DOCS -->"

read -r -d '' MCPM_SECTION << 'MCPM_EOF'



 ... (clipped 28 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Input handling: User prompt reads a single char without validating or timing out and appends heredoc
content to arbitrary existing files without verifying permissions or safe write semantics
(e.g., atomic writes/backup).

Referred Code
    echo
    echo -e "${CYAN}Found AI agent instruction file: $file${NC}"
    read -p "Would you like to add MCPM documentation reference? [y/N] " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        echo "$MCPM_SECTION" >> "$file"
        success "Added MCPM documentation reference to $file"
    fi
fi

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Dec 4, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Decouple AI integration from installer

The AI integration logic should be removed from the installation script.
Instead, it should be offered as a separate, post-install command like mcpm
setup-ai to keep the installer focused and make the integration an explicit user
action.

Examples:

pages/install [168-233]
setup_ai_agent_docs() {
    MCPM_CONFIG_DIR="$HOME/.config/mcpm"
    MCPM_LLM_TXT="$MCPM_CONFIG_DIR/llm.txt"
    LLM_TXT_URL="https://raw.githubusercontent.com/pathintegral-institute/mcpm.sh/main/llm.txt"

    # Download llm.txt to config directory
    info "Downloading MCPM documentation for AI agents..."
    mkdir -p "$MCPM_CONFIG_DIR"
    if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
        info "Saved AI agent documentation to $MCPM_LLM_TXT"

 ... (clipped 56 lines)

Solution Walkthrough:

Before:

# pages/install

setup_ai_agent_docs() {
    # ... download docs ...
    AI_INSTRUCTION_FILES=(...)
    for file in "${AI_INSTRUCTION_FILES[@]}"; do
        if [ -f "$file" ]; then
            read -p "Would you like to add MCPM documentation reference?"
            if [[ $REPLY =~ ^[Yy]$ ]]; then
                echo "$MCPM_SECTION" >> "$file"
            fi
        fi
    done
}

main() {
    # ... install steps ...
    setup_ai_agent_docs
}

After:

# pages/install

main() {
    # ... install steps ...
    # AI setup is removed from installer.
    info("To integrate with AI assistants, run 'mcpm setup-ai' after installation.")
}


# In the mcpm application (new command)
# mcpm setup-ai
def setup_ai_command():
    # ... download docs ...
    # ... find AI instruction files ...
    # ... prompt user and append docs ...
Suggestion importance[1-10]: 9

__

Why: This is a critical design suggestion that correctly points out that an installer should not modify unrelated user files, even with a prompt, as it violates the principle of least surprise and creates a brittle implementation.

High
Possible issue
Verify file write operation succeeds

Check if appending to the user's file was successful before printing a success
message, and report an error if the write operation fails.

pages/install [217-220]

 if [[ $REPLY =~ ^[Yy]$ ]]; then
-    echo "$MCPM_SECTION" >> "$file"
-    success "Added MCPM documentation reference to $file"
+    if echo "$MCPM_SECTION" >> "$file"; then
+        success "Added MCPM documentation reference to $file"
+    else
+        error "Failed to write to $file. Please check permissions."
+    fi
 fi
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: This is a valid error handling improvement that prevents the script from misleadingly reporting success when a file write operation fails, making the script more robust.

Medium
Improve error reporting for downloads

Remove the 2>/dev/null redirection from the curl command to allow its error
messages to be displayed, which will help with debugging download failures.

pages/install [176-180]

-if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
+if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT"; then
     info "Saved AI agent documentation to $MCPM_LLM_TXT"
 else
     info "Could not download llm.txt (will use GitHub URL as fallback)"
 fi
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that suppressing curl errors makes debugging difficult, and removing the redirection improves user feedback on installation issues without breaking the existing logic.

Low
  • Update

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pages/install (1)

167-224: Solid AI-doc integration; consider curl detection and non-interactive safety.

The overall approach (config dir + llm.txt download, marker-guarded block, opt‑in prompt) looks good and should be idempotent.

Two refinements worth considering:

  1. Handle systems without curl more explicitly

Right now a missing curl just falls into the generic “Could not download” branch, with the real error suppressed (2>/dev/null). A small guard would give clearer behavior on minimal systems:

-    info "Downloading MCPM documentation for AI agents..."
-    mkdir -p "$MCPM_CONFIG_DIR"
-    if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
-        info "Saved AI agent documentation to $MCPM_LLM_TXT"
-    else
-        info "Could not download llm.txt (will use GitHub URL as fallback)"
-    fi
+    info "Downloading MCPM documentation for AI agents..."
+    mkdir -p "$MCPM_CONFIG_DIR"
+    if command_exists curl; then
+        if curl -sSL "$LLM_TXT_URL" -o "$MCPM_LLM_TXT" 2>/dev/null; then
+            info "Saved AI agent documentation to $MCPM_LLM_TXT"
+        else
+            info "Could not download llm.txt (will use GitHub URL as fallback)"
+        fi
+    else
+        info "curl not found; will only reference remote docs URL in AI agent instructions"
+    fi
  1. Avoid surprises under set -e in non-interactive runs

read -p under set -e will cause the script to exit if stdin is already at EOF (e.g. non-interactive automation). A simple TTY check before prompting avoids that:

-    for file in "${AI_INSTRUCTION_FILES[@]}"; do
+    # Skip interactive prompts when stdin is not a TTY (e.g., automated installs)
+    if [ ! -t 0 ]; then
+        info "Non-interactive shell detected; skipping AI agent documentation prompts"
+        return
+    fi
+
+    for file in "${AI_INSTRUCTION_FILES[@]}"; do

Optionally, you could also gate the setup_ai_agent_docs call in main so it only runs when mcpm is actually on PATH:

-    verify_installation
-    setup_ai_agent_docs
+    verify_installation
+    if command_exists mcpm; then
+        setup_ai_agent_docs
+    fi

This keeps the integration robust in both interactive and automated install flows while preserving your current UX.

Also applies to: 233-233

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7fa277 and 1d88d37.

📒 Files selected for processing (1)
  • pages/install (2 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants